<?php 
namespace Material\Controller;

use Admin\Controller\AdminbaseController;
class SingleadminController extends AdminbaseController{
	
	protected $m;
	
	function _initialize() {
		parent::_initialize();
		$this->m = D('MaterialSingle');
	}
	
	
	/**
	 * @name 资讯列表
	 * @auth adminleft
	 */
	public function index(){
		$this->key = I('get.key','');
		$this->info = $this->m->where(array('key'=>$this->key))->find();
		$this->display();
	}
	
	

	
	public function edit_post(){
		if(IS_POST){
			$_POST['update_time'] = Date('Y-m-d H:i:s');
			$id = $this->m->where(array('key'=>$_POST['key']))->getField('id');
			if($id){
				$_POST['id'] = $id;
				$this->m->create();
				if($this->m->save()){
					$this->success('更新成功');
				}else{
					$this->error('更新失败');
				}
			}else{
				$_POST['create_time'] = Date('Y-m-d H:i:s');
				$this->m->create();
				$id = $this->m->add();
				if($id){
					$this->success('保存成功');
				}else{
					$this->error('保存失败');
				}
			}
		}
	}
}
	

?>